<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>班级学生列表</title>
        <link rel="stylesheet" href="css/bootstrap.min.css"/>
        <link rel="stylesheet" href="css/style.css"/>
        <script src="js/jquery-3.4.1.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src="js/script.js" charset="UTF-8"></script>
    </head>
    <script>
        // 高亮当前分页
        $(document).ready(function () {
            $("#li${requestScope.page.pageNo}").attr("class","active");
        })
    </script>
    <body>

            <br>
            <h1 class="text-center text-success">${param.batchName}班学生列表</h1>
            <hr>
            <br>

            <table id="dataTable" class="table table-hover">
                <tr>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>密码</th>
                    <th>性别</th>
                    <th>班级</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${requestScope.page.datalist}" var="s">
                    <!--这里为了能够从数据库删除学生的同时，删除当前tr元素，所以给了每个tr一个id，可自定义，这里是用tr学号作为tr元素的id-->
                    <tr id="tr${s.sid}">
                        <td>${s.sid}</td>
                        <td>${s.sname}</td>
                        <td>${s.spassword}</td>
                        <td>${s.sgender}</td>
                        <td>${s.sbatch}</td>
                        <td>
                            <a href="javascript:deleteStudent('${s.sid}');">删除</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>

            <div class="text-center">
                <nav aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="sblbp?pageNo=1&batchName=${param.batchName}">首页</a>
                        </li>
                        <li>
                            <a href="sblbp?pageNo=${requestScope.page.previousPage}&batchName=${param.batchName}">
                                <span>&laquo; 上一页</span>
                            </a>
                        </li>
                        <c:forEach begin="1" end = "${requestScope.page.totalPages}" var="item" varStatus="status">
                            <li id='li${status.current}'>
                                <a href="sblbp?pageNo=${item}&batchName=${param.batchName}">${item}</a>
                            </li>
                        </c:forEach>
                        <li>
                            <a href="sblbp?pageNo=${requestScope.page.nextPage}&batchName=${param.batchName}">下一页 &raquo;</a>
                        </li>
                        <li>
                            <a href="sblbp?pageNo=${requestScope.page.totalPages}&batchName=${param.batchName}">尾页</a>
                        </li>
                    </ul>
                </nav>
            </div>
            

            <br>
            <br>
        </div>
    </body>
</html>
